package designPattern.observer.asynchronous;

import designPattern.observer.asynchronous.event.ObserverEvent;
import designPattern.observer.asynchronous.observer.Observer;

public class Invoker {

	private Observer observer;
    private Handler handler;
    private ObserverEvent event;

    public Invoker(Observer observer) {
    	handler=new Handler();
        this.observer = observer;
    }

    private class Handler extends Thread {
        @Override
        public void run() {
        	observer.action(event);
        }
    }

    public void invoke(ObserverEvent event) {
    	this.event=event;
        handler.start();
    }
}
